/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"BF65190A-DD1F-4233-982F-181D7B5DE5F6"}
 */
function onDataChange_importe(oldValue, newValue, event) 
{
	if (neto >0 && tarifa >0)
	{
		if (liq_detalle_to_viajes.tarifa_por_viaje != 1)
	  	{ 
	  		var aux_importe = globals.operacion(neto,"*",tarifa)
	  		aux_importe = globals.operacion(aux_importe,"/",1000)
	  	}
	  	else
		{
	  		aux_importe = globals.operacion(tarifa,"*",1)
	  	}
		
		importe=aux_importe;
		importe_referencia=importe; //  16/04/2012
		tarifa_referencia=tarifa;   //  16/04/2012
		totalizar();
		return true;
	}
	else
		return false;
}

/**
 * @properties={typeid:24,uuid:"0D0D135D-4018-4D93-B850-778D6678DA28"}
 */
function totalizar() {
	globals.gtotal_detalle=0.00
	for ( var i = 1 ; i <= controller.getMaxRecordIndex(); i++ )
	{
		controller.setSelectedIndex(i)
		globals.gtotal_detalle = globals.operacion(globals.gtotal_detalle,"+",importe)
	} 
	//  comprobar lo sig.
	forms.liq_ncyd_viajes.subtotal1=globals.gtotal_detalle
	forms.liq_ncyd_viajes.subtotal0=globals.gtotal_detalle  // 16/04/2012
	
	var aux_porc_comision = globals.gPorcenComision //22/11/2012 toma % de comisión de variable global
	if (forms.liq_ncyd_viajes.fCalc_comision != 1)
	{
		var aux_porc_comision = 0
	}
	var aux_red = globals.operacion(forms.liq_ncyd_viajes.subtotal1,"*",aux_porc_comision) 
	forms.liq_ncyd_viajes.comision = globals.operacion(aux_red,"/",100)
	forms.liq_ncyd_viajes.neto = globals.operacion(forms.liq_ncyd_viajes.subtotal1,"-",forms.liq_ncyd_viajes.comision);
	var aux_red = globals.operacion(forms.liq_ncyd_viajes.neto,"*",forms.liq_ncyd_viajes.vporc_iva)
	forms.liq_ncyd_viajes.iva1_imp= globals.operacion(aux_red,"/",100)
	forms.liq_ncyd_viajes.iva1_porc=forms.liq_ncyd_viajes.vporc_iva
	forms.liq_ncyd_viajes.total= globals.operacion(forms.liq_ncyd_viajes.neto,"+",forms.liq_ncyd_viajes.iva1_imp)
}
